﻿using System;
using System.Threading.Tasks;

namespace EShop.Net.Model
{
    /// <summary>
    /// WebApi返回结果统一包装
    /// </summary>
    public class ResponseResultJson
    {
        /// <summary>
        /// 响应状态码
        /// </summary>
        private int code;

        /// <summary>
        /// 响应消息
        /// </summary>
        private string message;

        /// <summary>
        /// 响应结果
        /// </summary>
        private object data;

        public ResponseResultJson()
        {
        }

        public int Code { get => code; set => code = value; }
        public string Message { get => message; set => message = value; }
        public object Data { get => data; set => data = value; }

        /// <summary>
        /// WebApi返回结果
        /// </summary>
        /// <param name="code">响应状态码</param>
        /// <param name="message">响应信息</param>
        /// <param name="data">数据</param>
        /// <returns>WebApi返回结果</returns>
        public static ResponseResultJson ResponseResult(int code, string message, object data)
        {
            return new ResponseResultJson
            {
                Code = code,
                Message = message,
                Data = data
            };
        }
    }
}
